using System;
using System.Collections.Generic;

namespace Terra.Core.Common.Models.Common;

/// <summary>
/// 键值对DTO，用于简单的下拉选择
/// </summary>
/// <typeparam name="TKey">键类型</typeparam>
public class KeyValueDto<TKey>
{
    /// <summary>
    /// 键
    /// </summary>
    public TKey Key { get; set; }

    /// <summary>
    /// 值
    /// </summary>
    public string Value { get; set; }
}

/// <summary>
/// 选择项DTO，用于下拉选择框
/// </summary>
/// <typeparam name="TKey">主键类型</typeparam>
public class SelectOptionDto<TKey>
{
    /// <summary>
    /// 选项值
    /// </summary>
    public TKey Value { get; set; }

    /// <summary>
    /// 选项标签
    /// </summary>
    public string Label { get; set; }

    /// <summary>
    /// 是否禁用
    /// </summary>
    public bool Disabled { get; set; }

    /// <summary>
    /// 额外数据
    /// </summary>
    public object Data { get; set; }
}

/// <summary>
/// 分组选择项DTO，用于分组下拉选择框
/// </summary>
/// <typeparam name="TKey">选项主键类型</typeparam>
public class SelectGroupDto<TKey>
{
    /// <summary>
    /// 分组标签
    /// </summary>
    public string Label { get; set; }

    /// <summary>
    /// 分组选项
    /// </summary>
    public List<SelectOptionDto<TKey>> Options { get; set; } = new List<SelectOptionDto<TKey>>();
}

/// <summary>
/// 级联选择项DTO，用于级联选择框
/// </summary>
/// <typeparam name="TKey">主键类型</typeparam>
public class CascaderOptionDto<TKey>
{
    /// <summary>
    /// 选项值
    /// </summary>
    public TKey Value { get; set; }

    /// <summary>
    /// 选项标签
    /// </summary>
    public string Label { get; set; }

    /// <summary>
    /// 是否禁用
    /// </summary>
    public bool Disabled { get; set; }

    /// <summary>
    /// 是否为叶子节点
    /// </summary>
    public bool IsLeaf { get; set; }

    /// <summary>
    /// 子选项
    /// </summary>
    public List<CascaderOptionDto<TKey>> Children { get; set; } = new List<CascaderOptionDto<TKey>>();
}

/// <summary>
/// 树选择节点DTO，用于树形选择控件
/// </summary>
/// <typeparam name="TKey">主键类型</typeparam>
public class TreeSelectNodeDto<TKey>
{
    /// <summary>
    /// 节点键
    /// </summary>
    public TKey Key { get; set; }

    /// <summary>
    /// 节点标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 是否禁用选择
    /// </summary>
    public bool Disabled { get; set; }

    /// <summary>
    /// 是否可选
    /// </summary>
    public bool Selectable { get; set; } = true;

    /// <summary>
    /// 是否选中
    /// </summary>
    public bool Selected { get; set; }

    /// <summary>
    /// 是否展开
    /// </summary>
    public bool Expanded { get; set; }

    /// <summary>
    /// 是否勾选
    /// </summary>
    public bool Checked { get; set; }

    /// <summary>
    /// 自定义图标
    /// </summary>
    public string Icon { get; set; }

    /// <summary>
    /// 子节点
    /// </summary>
    public List<TreeSelectNodeDto<TKey>> Children { get; set; } = new List<TreeSelectNodeDto<TKey>>();
}

/// <summary>
/// 常用的Guid主键选择项
/// </summary>
public class SelectOption : SelectOptionDto<Guid>
{
}

/// <summary>
/// 常用的字符串主键选择项
/// </summary>
public class StringSelectOption : SelectOptionDto<string>
{
}

/// <summary>
/// 常用的整型主键选择项
/// </summary>
public class IntSelectOption : SelectOptionDto<int>
{
}